package game.roles.bullets;

import game.frame.MainFrame;
import game.roles.Role;
import game.roles.enemys.EnemyRole;
import game.roles.visual.BackgroundMaps;
import game.roles.visual.Blast;
import game.utils.ImageChange;
import game.utils.PressListenerOne;

import java.awt.*;

/**
 * @author liuyulai
 * Created with IntelliJ IDEA.
 * Date: 21.5.11
 * Time: 13:22
 * Description: No Description
 */
public class BigBoom extends Role implements GamerBullet {
    public static Image[] bigBooms;

    private ImageChange rm = new ImageChange(3);

    private int count = 0;

    public BigBoom(int x, int y) {
        super(x, y, 120, 120);
    }

    @Override
    public void rolesMove() {
        this.img = rm.change(bigBooms);
        for (int i = 0; i < MainFrame.roleList.size(); i++) {
            Role r = MainFrame.roleList.get(i);
            if (r instanceof EnemyRole && this.rec.intersects(r.rec)) {
                EnemyRole s1 = (EnemyRole) r;
                s1.byHit(1000);
                MainFrame.roleList.remove(this);
                MainFrame.roleList.add(new Blast(this.x, this.y));
                return;
            } else if (count >= 20) {
                //移除炸弹效果
                MainFrame.roleList.remove(this);
            }
        }
        count++;
        if (!BackgroundMaps.mapMoveOrNot) {
            return;
        }
        if (PressListenerOne.isRight && BackgroundMaps.mapMoveOrNot) {
            this.x -= 2;
        } else if (!PressListenerOne.isRight) {
            this.x -= 1;
        }
    }
}
